/*
 * Copyright (C) 2010-2011 Comcast Cable.  All Rights Reserved.
 */
package com.hercules.android.receiver.handlers.commands;

/**
 * This exception is raised by XREAggregateCommandHandler if the host sends a bad command index.
 * <p>
 * Note the exception will not be actually propagated but processed by XRECommandErrorHandler instead. It extends
 * XRECommandHandlerException.
 * <p>
 * <b>Thread Safety:</b> This class is not thread safe as its base class is not thread safe.
 *
 * @author liuliquan, 7realm
 * @version 1.0
 */
public class XREBadCommandIndexException extends XRECommandHandlerException {
    /** Serial version UID. */
    private static final long serialVersionUID = -2156203142755558720L;
    /**
     * The bad command index.
     * <p>
     * Initialized in constructor and will not change after. Can be any value. It has a getter.
     */
    private final int badCommandIndex;

    /**
     * Creates a new instance of XREBadCommandIndexException with given error message and bad command index.
     *
     * @param message the error message
     * @param badCommandIndex the bad command index
     */
    public XREBadCommandIndexException(String message, int badCommandIndex) {
        super(message);
        this.badCommandIndex = badCommandIndex;
    }

    /**
     * Creates a new instance of XREBadCommandIndexException with given error message, the cause and the bad command
     * index.
     *
     * @param message the error message
     * @param cause the cause of the exception
     * @param badCommandIndex the bad command index
     */
    public XREBadCommandIndexException(String message, Throwable cause, int badCommandIndex) {
        super(message, cause);
        this.badCommandIndex = badCommandIndex;
    }

    /**
     * Gets the bad command index.
     *
     * @return the bad command index
     */
    public int getBadCommandIndex() {
        return badCommandIndex;
    }
}